package com.zyg.function;

import java.util.function.Function;

public class MyFunctionDemo {
    public static void main(String[] args) {
        String str1 = "123";
        //convert1(str1, s -> Integer.parseInt(s) + 10, s -> s + "");
        Integer num1 = 10;
        convert2(num1,s->Integer.parseInt(s),s->s*s+"");
    }

    public static void convert1(String str, Function<String, Integer> function1, Function<Integer, String> function2) {
        String apply = function1.andThen(function2).apply(str);
        System.out.println(apply);
    }

    public static void convert2(Integer num, Function<String, Integer> function1, Function<Integer, String> function2) {
        Integer apply = (Integer) Function.identity().compose(function1).compose(function2).apply(num);
        System.out.println(apply);
    }

}
